package lock.redis;

import org.redisson.config.Config;

import java.io.File;
import java.io.IOException;

/**
 * redis 分布式锁实现
 *
 * @author fengpeng
 * @date 2019-06-24  17:45
 */
public class RedisDistributedLock {

    /**
     * 获取redission的配置
     *
     * @return
     */
    private static Config getConfig(){
        Config config = new Config();
        config.useClusterServers()
                // use "rediss://" for SSL connection
                // 10.10.168.231:7000,10.10.168.231:7001,10.10.168.231:7002,10.10.168.231:7003,10.10.168.231:7004,10.10.168.231:7005
                .addNodeAddress("10.10.168.231:7000",
                        "10.10.168.231:7001",
                        "10.10.168.231:7002",
                        "10.10.168.231:7003",
                        "10.10.168.231:7004",
                        "10.10.168.231:7005");

         // or read config from file
        try {
            config = Config.fromYAML(new File("config-file.yaml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return config;
    }

}
